package com.halflife.mathematics;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaoyf on 2018/2/15.
 */
public class PrimeNumber {

    @Test
    public void factor(){
        int compositeNumber = 18;
        List<Integer> primeList = new ArrayList<>();
        for(int i=2;i<=compositeNumber;i++){
            if(compositeNumber%i==0){
                primeList.add(i);
                compositeNumber/=i;
                i--;
            }
        }
        System.out.println(primeList);
    }
}

